<template>
  <div class="login">
    <div class="w content">
      <div class="box">
        <div class="flag">
          <span :class="active === 0 ? 'active' : null" @click="changeFlag(0)"
            >账户登录</span
          >
          <span :class="active === 1 ? 'active' : null" @click="changeFlag(1)"
            >扫码登录</span
          >
        </div>
        <component :is="flagComponent"></component>
      </div>
    </div>
  </div>
</template>

<script>
import zhanghuLoginComponent from "./components/zhanghuLogin";
import saomaLoginComponent from "./components/saomaLogin";
export default {
  name: "login",
  components: { zhanghuLoginComponent, saomaLoginComponent },
  data() {
    return {
      active: 0, // 0 账户登录，1 扫码登录
      flagComponent: "zhanghuLoginComponent",
    };
  },
  created() {
    // setTimeout(() => {
    //   this.$router.push(this.$route.query.path);
    // }, 2000);
  },
  methods: {
    changeFlag(flag) {
      console.log("点击了", flag);
      this.active = flag;
      if (flag === 0) {
        this.flagComponent = "zhanghuLoginComponent";
      } else {
        this.flagComponent = "saomaLoginComponent";
      }
    },
  },
  computed: {},
};
</script>

<style lang="less" scoped>
.login {
  background-color: #fbfcfe;
  .content {
    position: relative;
    height: calc(100vh - 377px - 90px);
    padding-left: 350px;

    background: url("../../assets/images/ce.jpg") no-repeat left top/350px 100%;
    .box {
      position: absolute;
      height: 600px;
      width: 600px;
      top: 50%;
      left: 460px;
      transform: translateY(-50%);
      background-color: #ffffff;
      .flag {
        display: flex;
        align-items: center;
        height: 55px;
        border-bottom: 1px solid #f4f4f4;
        // line-height: 55px;
        font-size: 18px;
        color: #666666;
        > span {
          flex: 1;
          text-align: center;
          &:hover {
            color: @globalColor;
            cursor: pointer;
            font-weight: bold;
          }
          &.active {
            color: @globalColor;
            cursor: pointer;
            font-weight: bold;
          }
        }
      }
    }
  }
}
</style>
